import pandas as pd
import matplotlib.pyplot as plt
from matplotlib.font_manager import FontProperties

# 读取CSV文件
data = pd.read_csv("cleaned_data.csv")

# 根据season列分组并计算每个季节的count总和
season_counts = data.groupby('season')['count'].sum()

# 设置中文字体
plt.rcParams['font.sans-serif'] = ['SimHei']  # 设置中文字体为宋体

# 绘制饼图
plt.figure(figsize=(8, 6))
labels = ['春天', '夏天', '秋天', '冬天']
colors = ['#ff9999', '#66b3ff', '#99ff99', '#ffcc99']
plt.pie(season_counts, labels=labels, colors=colors, autopct='%1.1f%%', startangle=140)
plt.title('不同季节租车人数占比')  # 使用系统默认的中文字体
plt.axis('equal')  # 保持饼图圆形
plt.show()


